package fr.mycompany.rce.ws.v1_0;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import com.exception.ws.BusinessException;
import com.exception.ws.TechnicalException;

@Component("rceWsConnector")
@Scope(proxyMode=ScopedProxyMode.INTERFACES)
@DependsOn("wsClientPortType")
public class RCEWsConnectorImpl implements RCEWsConnector {
	
	private static Logger log = LoggerFactory.getLogger(RCEWsConnectorImpl.class);

	@Autowired
	private OBK90L00Soap wsClientPortType;
	
	private RequestStrategy requestStrategy;
		
	
	public final void setRequestStrategy(RequestStrategy requestStrategy) {
		this.requestStrategy = requestStrategy;
	}

	/**{@inheritDoc}
	 * @see fr.mycompany.rce.ws.v1_0.RCEWsConnector#callMethod(java.lang.String)
	 */
	public BK90L00Output callMethod(String input) throws TechnicalException, BusinessException {
		
		BK90L00Input bk90L00Input;
		if(this.requestStrategy == null) {
			this.requestStrategy = new MockRequestStrategy("rce-mock-request");
		}
		bk90L00Input = requestStrategy.createRequest(input);
		
		BK90L00Output response = wsClientPortType.bk90L00(bk90L00Input);
		log.info(" call ws return  this response: {}",response);
		return response;
	}

}
